package com.ruoyi.web.controller.business;

import com.ruoyi.business.domain.dto.DeviceDTO;
import com.ruoyi.business.service.FeignService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lxy
 * @date 2024/2/19
 */
@Api(value = "开放接口", tags = {"开放接口模块"})
@RestController
@RequestMapping("/business/open")
public class OpenController extends BaseController {

    /*
    log 记录
    18:08:44.760 [http-nio-8080-exec-2] INFO  c.r.b.s.FeignService - [getBinghuToken,136] - 强制刷新冰狐Token
    18:08:45.210 [http-nio-8080-exec-2] INFO  c.r.b.s.FeignService - [fetchNewToken,160] - 远程调用冰狐接口-获取token:5B44ADC4EAA30FA6F4B7F41AB1673173
    18:08:45.341 [http-nio-8080-exec-2] INFO  c.r.b.s.FeignService - [parseResponse,116] - 解析响应成功: {"state":1,"data":{"total":20,"list":[{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"CF7mdS-MI 9","days":-1,"uuid":"f9f36c951adb71fa2e30e138b3462fde","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"fyFfzo-PCAM10","days":-1,"uuid":"22d597c861fbe5c4f69873e1d3905edf","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"PMh4Ly-MI 9","days":-1,"uuid":"381947cb6d2ace72447b477abe42ecc5","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李佳威-MI 9-公牛插座","days":-1,"uuid":"84b782326aa001104860ffdf11b2cb6f","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李佳威-MI 9-烧屏","days":-1,"uuid":"386d6928d3dc8ee16e638a128f8f57cc","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李佳威-MIX 3-碎屏","days":-1,"uuid":"2d3bed92d451e56832ae5e5c52860cbb","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李新宇-MI 9-快乐星球","days":-1,"uuid":"fe10126bcd5d82fb20bae3a444d79983","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李新宇-MI 9-镜头环","days":-1,"uuid":"e27564b01f16d6c0fa6abaa4b77f6263","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李新宇-MIX 3-无碎屏","days":-1,"uuid":"cdc9573a6034d40e970a77f3e398a4e8","onlineState":1},{"devState":0,"phoneNumber":"","enable":true,"workState":1,"name":"杨建-红米note10","days":-1,"uuid":"ad4979deb0a5c8034f7615d093d1e5b9","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"杰-MIX2S-黑皮","days":-1,"uuid":"1619c375921dfa09a37c2c92b9a865d0","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"杰-小米9-银紫碎屏","days":-1,"uuid":"5299747a87f95446eeb79e21ae3da708","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8-2517","days":-1,"uuid":"b859f874e339910d296bcdacef6f48b0","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"采购-MI8-4367","days":-1,"uuid":"7e94c4ef3f71a6d6d636a1e687349f66","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8-4367","days":-1,"uuid":"ff878c82719f0782262c5b638514c532","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8-6800","days":-1,"uuid":"082ead2c650e9a233d3bc6a0bf40a152","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8UD","days":-1,"uuid":"850ce1df32438d96e0cb8da59a5c131f","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI9-5772","days":-1,"uuid":"be02b06b152b56322e7cf387902fe106","onlineState":1},{"devState":0,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MIX3-无皮","days":-1,"uuid":"69864a6736dda20669a6a3423fb74165","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购有锁-MI8-4143","days":-1,"uuid":"d0671656af836752ee9f327dcd6206fb","onlineState":1}]}}
    18:08:53.143 [http-nio-8080-exec-10] INFO  c.r.b.s.FeignService - [getBinghuToken,140] - 返回缓存中的冰狐Token
    18:08:53.261 [http-nio-8080-exec-10] INFO  c.r.b.s.FeignService - [parseResponse,116] - 解析响应成功: {"state":1,"data":{"total":20,"list":[{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"CF7mdS-MI 9","days":-1,"uuid":"f9f36c951adb71fa2e30e138b3462fde","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"fyFfzo-PCAM10","days":-1,"uuid":"22d597c861fbe5c4f69873e1d3905edf","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"PMh4Ly-MI 9","days":-1,"uuid":"381947cb6d2ace72447b477abe42ecc5","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李佳威-MI 9-公牛插座","days":-1,"uuid":"84b782326aa001104860ffdf11b2cb6f","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李佳威-MI 9-烧屏","days":-1,"uuid":"386d6928d3dc8ee16e638a128f8f57cc","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李佳威-MIX 3-碎屏","days":-1,"uuid":"2d3bed92d451e56832ae5e5c52860cbb","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李新宇-MI 9-快乐星球","days":-1,"uuid":"fe10126bcd5d82fb20bae3a444d79983","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李新宇-MI 9-镜头环","days":-1,"uuid":"e27564b01f16d6c0fa6abaa4b77f6263","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李新宇-MIX 3-无碎屏","days":-1,"uuid":"cdc9573a6034d40e970a77f3e398a4e8","onlineState":1},{"devState":0,"phoneNumber":"","enable":true,"workState":1,"name":"杨建-红米note10","days":-1,"uuid":"ad4979deb0a5c8034f7615d093d1e5b9","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"杰-MIX2S-黑皮","days":-1,"uuid":"1619c375921dfa09a37c2c92b9a865d0","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"杰-小米9-银紫碎屏","days":-1,"uuid":"5299747a87f95446eeb79e21ae3da708","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8-2517","days":-1,"uuid":"b859f874e339910d296bcdacef6f48b0","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"采购-MI8-4367","days":-1,"uuid":"7e94c4ef3f71a6d6d636a1e687349f66","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8-4367","days":-1,"uuid":"ff878c82719f0782262c5b638514c532","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8-6800","days":-1,"uuid":"082ead2c650e9a233d3bc6a0bf40a152","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8UD","days":-1,"uuid":"850ce1df32438d96e0cb8da59a5c131f","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI9-5772","days":-1,"uuid":"be02b06b152b56322e7cf387902fe106","onlineState":1},{"devState":0,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MIX3-无皮","days":-1,"uuid":"69864a6736dda20669a6a3423fb74165","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购有锁-MI8-4143","days":-1,"uuid":"d0671656af836752ee9f327dcd6206fb","onlineState":1}]}}
    18:09:20.459 [http-nio-8080-exec-1] INFO  c.r.b.s.FeignService - [getBinghuToken,140] - 返回缓存中的冰狐Token
    18:09:20.575 [http-nio-8080-exec-1] INFO  c.r.b.s.FeignService - [parseResponse,116] - 解析响应成功: {"state":1,"data":{"total":20,"list":[{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"CF7mdS-MI 9","days":-1,"uuid":"f9f36c951adb71fa2e30e138b3462fde","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"fyFfzo-PCAM10","days":-1,"uuid":"22d597c861fbe5c4f69873e1d3905edf","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"PMh4Ly-MI 9","days":-1,"uuid":"381947cb6d2ace72447b477abe42ecc5","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李佳威-MI 9-公牛插座","days":-1,"uuid":"84b782326aa001104860ffdf11b2cb6f","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李佳威-MI 9-烧屏","days":-1,"uuid":"386d6928d3dc8ee16e638a128f8f57cc","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李佳威-MIX 3-碎屏","days":-1,"uuid":"2d3bed92d451e56832ae5e5c52860cbb","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李新宇-MI 9-快乐星球","days":-1,"uuid":"fe10126bcd5d82fb20bae3a444d79983","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李新宇-MI 9-镜头环","days":-1,"uuid":"e27564b01f16d6c0fa6abaa4b77f6263","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"李新宇-MIX 3-无碎屏","days":-1,"uuid":"cdc9573a6034d40e970a77f3e398a4e8","onlineState":1},{"devState":0,"phoneNumber":"","enable":true,"workState":1,"name":"杨建-红米note10","days":-1,"uuid":"ad4979deb0a5c8034f7615d093d1e5b9","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"杰-MIX2S-黑皮","days":-1,"uuid":"1619c375921dfa09a37c2c92b9a865d0","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"杰-小米9-银紫碎屏","days":-1,"uuid":"5299747a87f95446eeb79e21ae3da708","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8-2517","days":-1,"uuid":"b859f874e339910d296bcdacef6f48b0","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":0,"name":"采购-MI8-4367","days":-1,"uuid":"7e94c4ef3f71a6d6d636a1e687349f66","onlineState":0},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8-4367","days":-1,"uuid":"ff878c82719f0782262c5b638514c532","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8-6800","days":-1,"uuid":"082ead2c650e9a233d3bc6a0bf40a152","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI8UD","days":-1,"uuid":"850ce1df32438d96e0cb8da59a5c131f","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MI9-5772","days":-1,"uuid":"be02b06b152b56322e7cf387902fe106","onlineState":1},{"devState":0,"phoneNumber":"","enable":true,"workState":1,"name":"采购-MIX3-无皮","days":-1,"uuid":"69864a6736dda20669a6a3423fb74165","onlineState":1},{"devState":1,"phoneNumber":"","enable":true,"workState":1,"name":"采购有锁-MI8-4143","days":-1,"uuid":"d0671656af836752ee9f327dcd6206fb","onlineState":1}]}}
    Disconnected from the target VM, address: '127.0.0.1:1204', transport: 'socket'
     */
    @Resource
    private FeignService feignService;

    @ApiOperation("获取设备列表")
    @GetMapping("/getDeviceList")
    public AjaxResult getDeviceList(@RequestParam(value = "onlineState", required = false) String onlineState) {
        List<DeviceDTO> deviceList = feignService.getDeviceList(onlineState);
        return AjaxResult.success(deviceList);
    }

    @ApiOperation("获取用户列表")
    @GetMapping("/user/info")
    public AjaxResult getSysUserByRpc() {
        SysUser list = feignService.getSysUserByRpc();
        return success(list);
    }
}
